package com.platform.api.bzproject.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.api.bzproject.dao.BzClassificationMapper;
import com.platform.api.bzproject.model.BzClassification;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author guoyunfei on 2021/7/9 14:03
 * @className BzClassificationMapper
 * @description TODO
 * @Version 1.0
 */
@Service
@Transactional(rollbackFor=Exception.class)
public class BzClassificationService extends ServiceImpl<BzClassificationMapper, BzClassification> {
    @Autowired
    private BzClassificationMapper bzClassificationMapper;

    public List<BzClassification> selectList(BzClassification classification){

        List<BzClassification> bzClassifications = bzClassificationMapper.selectList(new LambdaQueryWrapper<BzClassification>()
                .eq(null != classification.getEnable(),BzClassification::getEnable,classification.getEnable())
                .eq(null != classification.getAppid(),BzClassification::getAppid,classification.getAppid()));
        return bzClassifications;
    }


    public BzClassification selectOne(String className,String appid){

        QueryWrapper<BzClassification> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name",className);
        queryWrapper.eq("appid",appid);
        return this.getOne(queryWrapper);
    }


}
